<!--用户权限配置-->
<template>
  <div>
    <div class="ca_config_ul" v-loading="loading">
      <ul>
        <li>
          <label>配置说明</label>
          <span class="con">配置设置</span>
          <span class="trips">配置描述</span>
        </li>
        <li>
          <label>HIS预约成功后处理方式</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.browserCloseSet" clearable size="small" placeholder="请选择">
              <el-option value="1" label="不处理"></el-option>
              <el-option value="2" label="关闭浏览器"></el-option>
              <el-option value="3" label="关闭当前页"></el-option>
            </el-select>
          </span>
          <span class="trips">his打开临床预约,患者预约成功后的关闭方式</span>
        </li>
        <li v-if="isUserArea && isUserArea!= '未知'">
          <label>默认院区</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.areaName" clearable size="small" placeholder="请选择">
              <el-option
                v-for="(item, index) in areaNameOptions"
                :key="index"
                :value="item"
                :label="item"
              ></el-option>
            </el-select>
          </span>
          <span class="trips">页面是否启用只显示默认选中的院区</span>
        </li>
        <li v-if="!isUserArea && isUserArea!= '未知'">
          <label>默认影像区域</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.depAreaName" clearable size="small" placeholder="请选择">
              <el-option
                v-for="(item, index) in depAreaOptions"
                :key="index"
                :value="item"
                :label="item"
              ></el-option>
            </el-select>
          </span>
          <span class="trips">页面是否启用只显示默认选中的影像区域</span>
        </li>
        <li>
          <label>配置打印机名称</label>
          <span class="con">
            <el-input class="long-input" type="input" size="small" style="width: 161px;" v-model="formdata.markingMachineSet" placeholder="请输入打印机名称"></el-input>
          </span>
          <span class="trips">配置的打印机名称，优先级最高</span>
        </li>
        <li>
          <label>配置不自动打印的患者类型</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.unPrintPatTypeSet" clearable size="small" placeholder="请选择">
              <el-option value="门诊" label="门诊"></el-option>
              <el-option value="住院" label="住院"></el-option>
              <el-option value="体检" label="体检"></el-option>
              <el-option value="急诊" label="急诊"></el-option>
              <el-option value="绿检" label="绿检"></el-option>
              <el-option value="外院" label="外院"></el-option>
            </el-select>
          </span>
          <span class="trips">预约和改约后，不自动打印的设置，目前仅支持患者类型</span>
        </li>
        <li>
          <label>强制补充自动打印患者类型</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.clientPrintPatTypeSet" clearable size="small" placeholder="请选择">
              <el-option value="门诊" label="门诊"></el-option>
              <el-option value="住院" label="住院"></el-option>
              <el-option value="体检" label="体检"></el-option>
              <el-option value="急诊" label="急诊"></el-option>
              <el-option value="绿检" label="绿检"></el-option>
              <el-option value="外院" label="外院"></el-option>
            </el-select>
          </span>
          <span class="trips">预约和改约后，设置对应的患者类型强制设置自动打印</span>
        </li>
        <li>
          <label>强制补充住院床旁项目的患者自动打印</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.clientPrintChuangPangSet" clearable size="small" placeholder="请选择">
              <el-option value="" label="不设置，以服务器为准"></el-option>
              <el-option value="Y" label="是"></el-option>
              <el-option value="N" label="否"></el-option>
            </el-select>
          </span>
          <span class="trips">预约和改约后，设置对应的床旁患者是否自动打印</span>
        </li>
        <li>
          <label>本地自动打印是否启用lodop</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.lodopPrint" clearable size="small" placeholder="请选择">
              <el-option value="" label="不设置，以服务器为准"></el-option>
              <el-option value="Y" label="是"></el-option>
              <el-option value="N" label="否"></el-option>
            </el-select>
          </span>
          <span class="trips">当为false的时候，打印多了web自带的预览框，为true的时候要安装插件。</span>
        </li>
        <li>
          <label>纸张大小</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.paperSizeSet" clearable size="small" placeholder="请选择">
              <el-option
                v-for="(item, index) in pageSizeList"
                :key="index"
                :value="item.item"
                :label="item.item"
              ></el-option>
            </el-select>
          </span>
          <span class="trips">打印机纸张类型</span>
        </li>
        <li>
          <label>是否使用PDF打印</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.paperPrintPDF" clearable size="small" placeholder="请选择">
              <el-option value="" label="不设置，以服务器为准"></el-option>
              <el-option value="Y" label="是"></el-option>
              <el-option value="N" label="否"></el-option>
            </el-select>
          </span>
          <span class="trips">选择是代表启用PDF打印</span>
        </li>
        <li v-if="applyInfoHospital == 'fuding'">
          <label>是否关闭LODOP的打印预览</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.lodopPreviewSet" clearable size="small" placeholder="请选择">
              <el-option value="" label="不设置，以服务器为准"></el-option>
              <el-option value="Y" label="关闭"></el-option>
              <el-option value="N" label="不关闭"></el-option>
            </el-select>
          </span>
          <span class="trips">医院打印开启了lodop预览功能时，需要使用</span>
        </li>
        <li>
          <label>设置改约以后关闭对话框的时间</label>
          <span class="con">
            <el-input class="long-input" type="input" size="small" style="width: 161px;" v-model="formdata.defaultCloseChangeTime" placeholder="1000"></el-input>
          </span>
          <span class="trips">默认临床预约过1000毫秒后，通知医技预约关闭改约弹框，单位:毫秒</span>
        </li>
        <li>
          <label>改约不打印</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.lodopRebookPrint" clearable size="small" placeholder="请选择">
              <el-option value="" label="不设置，以服务器为准"></el-option>
              <el-option value="Y" label="是"></el-option>
              <el-option value="N" label="否"></el-option>
            </el-select>
          </span>
          <span class="trips">改约不打印</span>
        </li>
        <li>
          <label>预览改约后，是否启用小黑框	</label>
          <span class="con">
            <el-select filterable class="wd100" v-model="formdata.blackDialogOpen" clearable size="small" placeholder="请选择">
              <el-option value="" label="不设置，以服务器为准"></el-option>
              <el-option value="Y" label="启用"></el-option>
              <el-option value="N" label="不启用"></el-option>
            </el-select>
          </span>
          <span class="trips">当为false的时候，打印多了web自带的预览框，为true的时候要安装插件。</span>
        </li>
      </ul>
    </div>
    <div class="dialog-footer mar-t-10 flex flex-row justify-end" v-if="isshowbtn">
      <el-button size="small" @click="dialogVisible = false">取消</el-button>
      <el-button size="small" type="primary" @click="settingSend">保存</el-button>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
// import { getIsSetStorageAreaName } from '@/utils/utils'
// import { getLocalStorage } from '@/utils/localStorage' // removeLocalStorage
import { getDepAreaList, getItemList } from '@/api/api'
export default {
  props: {
    // 是否弹出右侧
    isshowbtn: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      dialogVisible: false,
      loading: false,
      appointSourceFlag: window.g.appointSourceFlag,
      userId: this.$store.state.user.id,
      userName: this.$store.state.user.userName,
      hospitalCode: this.$store.state.user.hospitalCode,
      applyInfoHospital: window.g.applyInfoHospital,
      modalitytypeOptions: [],
      depAreaOptions: [],
      depOptions: [], // 检查部门
      isUserArea: '未知',
      pageSizeList: [],
      formdata: {
        browserCloseSet: '',
        areaName: '',
        depAreaName: '',
        markingMachineSet: '',
        unPrintPatTypeSet: '',
        clientPrintPatTypeSet: '',
        clientPrintChuangPangSet: '',
        lodopPrint: '',
        paperSizeSet: '',
        paperPrintPDF: '',
        lodopPreviewSet: '',
        defaultCloseChangeTime: '1000',
        lodopRebookPrint: '',
        blackDialogOpen: ''
      }
    }
  },
  watch: {
    isshowbtn(val) {
      if (!val) {
        this.reset()
      }
    }
  },
  computed: {
    ...mapGetters(['areaNameOptions']),
    appConfig() {
      let appConfig = this.$store.state.settings.appConfig
      return appConfig
    }
  },
  async created() {
    try {
      this.isUserArea = this.$store.state.user.appSetting.isUserArea
    } catch (e) {
      this.isUserArea = '未知'
    }
    if (window.g.applyInfoHospital == 'fuding') {
      this.formdata.lodopPreviewSet = ''
    }
    // this.getTypeOptions()
    // console.log('this.formdata', this.formdata)
    await this.getAreaNameList()
    // 如果是影像楼选项
    if (this.isUserArea + '' == 'false') {
      this.getDepAreaAllList()
    }
    this.getPageList() // 纸张大小
  },
  mounted() {
  },
  methods: {
    reset() {
      this.formdata = {
        browserCloseSet: '',
        areaName: '',
        depAreaName: '',
        markingMachineSet: '',
        unPrintPatTypeSet: '',
        clientPrintPatTypeSet: '',
        clientPrintChuangPangSet: '',
        lodopPrint: '',
        paperSizeSet: '',
        paperPrintPDF: '',
        lodopPreviewSet: '',
        defaultCloseChangeTime: '1000',
        lodopRebookPrint: '',
        blackDialogOpen: ''
      }
      if (window.g.applyInfoHospital == 'fuding') {
        this.formdata.lodopPreviewSet = ''
      }
    },
    async getAreaNameList() {
      if (this.areaNameOptions.length == 0) {
        let params = { HospitalCode: this.hospitalCode }
        await this.$store.dispatch('settings/set_areaNameOptions', params)
      }
      // let params = { HospitalCode: this.hospitalCode }
      // await this.$store.dispatch('settings/set_areaNameOptions', params)
    },
    getDepAreaAllList() {
      let params = {
        HospitalCode: this.hospitalCode,
        DepArea: this.formdata.depArea,
        areaName: this.formdata.areaName
      }
      if (!this.formdata.depArea) {
        delete params.DepArea
      }
      return getDepAreaList(params).then(res => {
        if (res && res.code === 10000) {
          this.depAreaOptions = res.content.list
        }
      })
    },
    setFormData(data) {
      this.formdata = { ...this.formdata, ...data }
    },
    // 纸张大小
    getPageList() {
      let params = { HospitalCode: this.hospitalCode, type: '纸张类型' }
      getItemList(params).then(res => {
        if (res.code === 10000) {
          this.pageSizeList = res.content.list || []
          console.error('pageSizeList', this.pageSizeList)
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
  // /deep/ .wd100 {
  //   width: 160px !important;
  // }

  .ca_config_ul {
    width: 100%;
    display: flex;
    ul {
      width: 100%;
      margin: 0;
      padding: 0;
      border-bottom: 1px solid #EBEEF5;
      &:nth-child(1) {
        border-left: 1px solid #EBEEF5;
      }
      &:nth-child(2) {
        background: #FAFAFA;
      }
      li {
        display: flex;
        align-items: center;
        width: 100%;
        border-top: 1px solid #EBEEF5;
        border-right: 1px solid #EBEEF5;
        margin: 0;
        height: 42px;
        line-height: 42px;
        box-sizing: border-box;
        padding: 0 10px;
        color: #606266;
        label {
          width: 20%;
          min-width: 130px;
          line-height: 16px;
          font-weight: normal;
        }
        .con {
          width: 25%;
          border-left: 1px solid #EBEEF5;
          border-right: 1px solid #EBEEF5;
          box-sizing: border-box;
          padding: 0 10px;
          /deep/ .el-input--medium .el-input__inner {
            height: 32px;
            line-height: 32px;
          }
          // /deep/ .wd100 {
          //   width: 160px !important;
          // }
        }
        .trips {
          width: 60%;
          box-sizing: border-box;
          padding: 0 5px 0 10px;
          line-height: 18px;
          color: #999;
          font-size: 13px;
        }
        &:nth-child(1) {
          background: #00C0EF;
          color: #Fff;
          font-weight: 500;
          label {
            font-weight: 500;
          }
          .trips {
            color: #fff;
          }
        }
      }
    }
  }
</style>
